﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using LprMiddleWare.HangWang;

namespace LprMiddleWare.Model
{
    public class LicensePlate : INotifyPropertyChanged
    {
        public byte[] Image { get; set; }

        public bool IsViolation { get; set; }
        public string ViolationType { get; set; }
        public List<string> Videos { get; set; }

        public CaptureReason CaptureReason { get; set; }
        private int _speed;
        public int Speed
        {
            get { return _speed; }
            set
            {
                _speed = value;
                RaisePropertyChanged("Speed");
            }
        }

        private int _speedLimit;
        public int SpeedLimit
        {
            get { return _speedLimit; }
            set
            {
                _speedLimit = value;
                RaisePropertyChanged("SpeedLimit");
            }
        }

        private int _plateColor;
        public int PlateColor
        {
            get { return _plateColor; }
            set
            {
                _plateColor = value;
                RaisePropertyChanged("PlateColor");
            }
        }

        private int _detectMethod;
        public int DetectMethod
        {
            get { return _detectMethod; }
            set
            {
                _detectMethod = value;
                RaisePropertyChanged("DetectMethod");
            }
        }

        public int PlateType { get; set; }

        public int CarType { get; set; }

        private string _licenseNumber = string.Empty;
        public string LicenseNumber
        {
            get { return _licenseNumber; }
            set
            {
                _licenseNumber = value;
                RaisePropertyChanged("LicenseNumber");
            }
        }


        private string _deviceId;
        public string DeviceId
        {
            get { return _deviceId; }
            set
            {
                _deviceId = value;
                RaisePropertyChanged("DeviceId");
            }
        }

        private int _laneNo;
        public int LaneNo
        {
            get { return _laneNo; }
            set
            {
                _laneNo = value;
                RaisePropertyChanged("LaneNo");
            }
        }

        private int _cameraNo;
        public int CameraNo
        {
            get { return _cameraNo; }
            set
            {
                _cameraNo = value;
                RaisePropertyChanged("CameraNo");
            }
        }

        private string _direction;
        public string Direction
        {
            get { return _direction; }
            set
            {
                _direction = value;
                RaisePropertyChanged("Direction");
            }
        }

        private int _confidence;
        public int Confidence
        {
            get { return _confidence; }
            set
            {
                _confidence = value;
                RaisePropertyChanged("Confidence");
            }
        }

        /// <summary>
        /// The <see cref="CaptureTime" /> property's name.
        /// </summary>
        public const string CaptureTimePropertyName = "CaptureTime";

        private DateTime _captureTime;

        public DateTime CaptureTime
        {
            get
            {
                return _captureTime;
            }

            set
            {
                if (_captureTime == value)
                {
                    return;
                }

                _captureTime = value;
                // Update bindings, no broadcast
                RaisePropertyChanged(CaptureTimePropertyName);

            }
        }


        public event PropertyChangedEventHandler PropertyChanged;

        public void RaisePropertyChanged(string propetyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propetyName));
        }

        public bool IsSpeeding
        {
            get { return SpeedLimit != 0 && Speed > SpeedLimit; }
        }

    }
}
